#!/usr/bin/bash

path=`cd "$( dirname ${BASH_SOURCE[0]} )" && pwd`
cd $path
source config.sh
#检测系统类型
source $bin/get_platform.sh


tool=$1
version=$2
method=$3


if [[ $tool == '' || $method == '' || $version == '' ]];then
	echo ==================================
	echo 请选择需要卸载的开发工具
	echo 1.Python
	echo 2.Nodejs
	echo 3.Java
	echo ==================================
	read -p "请选择：" tool
	if [[ $tool = 1 ]];then
		tool=python
	elif [[ $tool = 2 ]];then
		tool=node
	elif [[ $tool = 3 ]];then
		tool=java
	else
		echo "没有这个选项。"
		exit
	fi

	echo ==================================
	echo 请选择需要卸载的方式
	echo python全版本暂无官方编译版本。请选择其他版本谢谢。
	echo nodejs全版本暂无自编译版本。请选择其他版本谢谢。
	echo 1.自动编译卸载
	echo 2.官方编译版本卸载
	echo ==================================
	read -p "请选择：" method



	#选择版本
	echo ==================================
	echo 请选择需要卸载的版本
	source $bin/recommend.sh $tool
	echo ==================================
	read -p "请选择：" version
	version=`sed -n "$version""p" $config/$tool/recommend/"$dev_env_system"_${dev_env_version%%"."*}_default.txt`
	version=${version#*" "}
	if [[ $version = "" ]];then
		echo "没有这个选项。"
		exit
	fi
fi
	
#开始卸载
echo ==================================
echo 开始卸载。。。
echo ==================================
if [[ $method = 2 ]];then
	source $bin/$tool/$dev_env_system/$version/uninstall.sh
elif [[ $method = 1 ]];then
	source $bin/$tool/$dev_env_system/$version/uncompile.sh
fi
source $bin/$tool/unexport.sh $tool $version
echo "清理缓存"
rm -rf $system_cache/$tool$version


